/*YUj0fMm/nDvETzMrBsusTI8Rae4AmnczppR9QAiwoEhjA+Z95x9MFwpxltFZ9HXb*/
/*
 * @Descripttion: 初始化查询
 * @version:
 * @Author: Chendch
 * @Date: 2020-10-14 13:49:13
 * @LastEditors: Chendch
 * @LastEditTime: 2021-06-22 10:33:00
 */
import { ajax, pageTo, toast } from 'nc-lightapp-front';
import {Urls} from "../CONSTANCE";

/**
    * 请求初始参数
    * @param callback : 1、获得envParam,2、处理元数据项 3、设置按钮状态
*/
function queryEnvParamUrl() {
    return new Promise( (resolve, reject) => {
        ajax({
            url: Urls.queryEnvParamUrl,
            data: {
                nodeType:this.props.nodeType || 'GLOBE_NODE',
                pk_curOrg:'',
            },
            success:(res)=>{
                resolve(res.data || {})
            },
            error: (res) => {
                toast({ content: msg.message, color: 'danger' });
                reject("error");
            }
        });
    })
}

/**
    * 请求初始参数
    * @param callback : 1、查询上下翻页数据
*/
function querySublingCardData(pk) {
    return new Promise( (resolve, reject) => {
        ajax({
            url: Urls.queryCardUrl,
            data: {
                pk_supplier:pk,
                pageCode:pageTo.getPageCode(),
                nodeType:this.props.nodeType,
                pk_curOrg:this.state.envParam.pk_org,
                status:this.state.status,//！！！新增取消时回滚单据号
            },
            success:(res)=>{
                const {success, data} = res;
                if(!success) resolve("error");
                resolve(data);
                resolve(res.data || {})
            },
            error: (res) => {
                toast({ content: msg.message, color: 'danger' });
                reject("error");
            }
        });
    })
}



export {
    queryEnvParamUrl,
    querySublingCardData
}
/*YUj0fMm/nDvETzMrBsusTI8Rae4AmnczppR9QAiwoEhjA+Z95x9MFwpxltFZ9HXb*/
